
finp2$="picture.png"
shell("convert "+finp2$+" -resize 288x192\\! _tmpr2.jpg")
finp$="_tmpr2.jpg"

'- corrigir leitura de cores (?)


xed=320:yed=600
setdisplay(xed,yed,32,1):paper(8^8-1):ink(0):pen(0):cls
loadimage(finp$,1):pasteicon(0,400,1)

for y=0 to 191
      v0=0
  for x1=0 to 39
        cflc=0
    for x2=0 to 6
        x=x2+(x1*7)
        apv=0 : cfl=0
        ind=point(x,y+400)
        b= ind mod 256: ind=int(ind/256)
        g= ind mod 256: ind=int(ind/256)
        r= ind mod 256

       prim=   (int(g/128))*4  +(int(r/128))*2  +(int(b/128)) 


          if prim=0 then : apv=0 : cfl=1 : end if   '- k
          if prim=3 then : apv=1 : cfl=0 : end if   '- m
          if prim=1 or prim=5 then : apv=1 : cfl=2 : end if   '- b
          if prim=4 then : apv=2 : cfl=0 : end if  '- g
          if prim=2 or prim=6 then : apv=2 : cfl=2 : end if   '- o
          if prim=7 then : apv=3 : cfl=1 : end if   '- w



       if(x mod 2)=0 then 
        if apv=0 or apv=2 then
          dot (x,y+200)
         end if 
        if apv=0 or apv=1 then 
          dot (x+1,y+200)
         end if 
       end if 
            cflc=cflc+cfl
    next
      if cflc<8 then
        dot (280+x1,y+200)
      end if 
  next
next

ink(0): bar(0,0,279,191)

for y=0 to 191
    ink(0xFF00FF)
  for x=0 to 279 step 2
    i=point(x,y+200) mod 256
    if i>127 then:dot(x,y): end if
  next
    ink(0x00FF00)
  for x=1 to 279 step 2
    i=point(x,y+200) mod 256
    if i>127 then:dot(x,y): end if
  next
    ink(0xFF00FF)
  for x=0 to 277 step 2
    i1=point(x,y+200) mod 256:i2=point(x+2,y+200) mod 256
    if i1>127 and i2>127 then:dot(x+1,y): end if
  next
    ink(0x00FF00)
  for x=1 to 277 step 2
    i1=point(x,y+200) mod 256:i2=point(x+2,y+200) mod 256
    if i1>127 and i2>127 then:dot(x+1,y): end if
  next
    ink(0xFFFFFF)
  for x=1 to 278
    i1=point(x,y+200) mod 256:i2=point(x+1,y+200) mod 256
    if i1>127 and i2>127 then:dot(x,y):dot(x+1,y): end if
  next
next

for y=0 to 191
  for x1=0 to 39
      q=point(280+x1,200+y) mod 256

    for x2=0 to 6
      n=point(x1*7+x2,y)

      if n=0xFF00FF and q>128 then: n=0x0000FF: end if
      if n=0x00FF00 and q>128 then: n=0xFF7F00: end if
      ink(n):dot(x1*7+x2,y)

    next
  next
next

fout$=finp$+".bmp"
grab (1,0,0,280,192):saveimage(fout$,1)

'waitkey



